<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <style>
        .layer_notice {
            float: left;
            /* height: 150px; */
            width: 150px;
            overflow: hidden;
            background: #5FB878;
            padding: 15px;
        }
        .layer_notice a {
            color: #fff;
            text-decoration: none;
            line-height: 25px;
            font-family: '\5FAE\8F6F\96C5\9ED1';
        }
    </style>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <blockquote class="layui-elem-quote">欢迎用户：
                        <span class="x-red" id="username"></span>
                    </blockquote>
                </div>
            </div>
        </div>
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">数据统计</div>
                <div class="layui-card-body ">
                    <ul class="layui-row layui-col-space10 layui-this x-admin-carousel x-admin-backlog">
                        <li class="layui-col-md3 layui-col-xs4">
                            <a class="x-admin-backlog-body">
                                <h3>经手合同数</h3>
                                <p><cite id="whole"></cite></p>
                            </a>
                        </li>
                        <li class="layui-col-md3 layui-col-xs6">
                            <a class="x-admin-backlog-body">
                                <h3>已确认合同数</h3>
                                <p><cite id="finish"></cite></p>
                            </a>
                        </li>
                        <li class="layui-col-md3 layui-col-xs6">
                            <a class="x-admin-backlog-body">
                                <h3>已转发未确认合同数</h3>
                                <p><cite id="being"></cite></p>
                            </a>
                        </li>
                        <li class="layui-col-md3 layui-col-xs6">
                            <a class="x-admin-backlog-body" >
                                <h3>未转发合同数</h3>
                                <p><cite id="un"></cite></p>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="layui-col-sm6 layui-col-md4">
            <div class="layui-card">
                <div class="layui-card-header">合同数
                    <span class="layui-badge layui-bg-cyan layuiadmin-badge">月</span></div>
                <div class="layui-card-body  ">
                    <p class="layuiadmin-big-font" id="month"></p>
                </div>
            </div>
        </div>
        <div class="layui-col-sm6 layui-col-md4">
            <div class="layui-card">
                <div class="layui-card-header">合同数
                    <span class="layui-badge layui-bg-cyan layuiadmin-badge">季</span></div>
                <div class="layui-card-body ">
                    <p class="layuiadmin-big-font" id="season"></p>
                </div>
            </div>
        </div>
        <div class="layui-col-sm6 layui-col-md4">
            <div class="layui-card">
                <div class="layui-card-header">合同数
                    <span class="layui-badge layui-bg-cyan layuiadmin-badge">年</span></div>
                <div class="layui-card-body ">
                    <p class="layuiadmin-big-font" id="year"></p>
                </div>
            </div>
        </div>
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">开发团队</div>
                <div class="layui-card-body ">
                    <table class="layui-table">
                        <tbody>
                        <tr>
                            <th>版权所有</th>
                            <td>李国伟、曾繁星</td>
                        </tr>
                        <tr>
                            <th>开发者</th>
                            <td>李国伟、曾繁星</td></tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <style id="welcome_style"></style>
        <div class="layui-col-md12">
            <blockquote class="layui-elem-quote layui-quote-nm">感谢layui,jquery,本系统由x-admin提供技术支持。</blockquote></div>
    </div>
</div>
<script>
    $('#username').html(sessionStorage.getItem("username"));
    if(sessionStorage.getItem("userId") != null || sessionStorage.getItem("userId") != "null") {
        $.ajax({
            url: '/indexDetails',
            type: 'POST',
            success: function (res) {
                console.log(res);
                if (res.msg == "success") {
                    $('#whole').html(res.data.whole);
                    $('#finish').html(res.data.confirm);
                    $('#being').html(res.data.send_notconfirm);
                    $('#un').html(res.data.notsend);
                    $('#month').html(res.data.Statistics.m);
                    $('#season').html(res.data.Statistics.j);
                    $('#year').html(res.data.Statistics.y);
                    layui.use('layer', function () {
                        var layer = layui.layer;
                        var textArr = "";
                        for (let i = 1; i <= res.data.RemindInfo.length; i++) {
                            var text = i + ' ）  合同id: ' + res.data.RemindInfo[i - 1].tableId + '  项目名: ' + res.data.RemindInfo[i - 1].projectName + '<br/>';
                            textArr += text;
                        }
                        if (res.data.RemindInfo.length > 0) {
                            layer.alert(textArr, {
                                title: '注意！ 你有新的提醒！ '
                                , skin: 'layui-layer-molv' //样式类名
                                , anim: 1
                                , shade: [0.8, '#393D49']
                                , closeBtn: 1
                            }, function () {
                                layer.alert(' 请尽快完成哦! ', {
                                    skin: 'layui-layer-lan'
                                    , title: '注意！ 你有新的提醒！'
                                    , closeBtn: 1
                                    ,  shade: [0.8, '#393D49']
                                    , anim: 4 //动画类型
                                });
                            });
                        }
                    });
                }
            }
        })
    }
</script>
<script>
    function isEmpty(val){
        if(val == null || val == 'undefined' || val == ''){
            return null;
        } else {
            return val;
        }
    }
</script>
<script>
    var url = sessionStorage.getItem("prevUrl");
    var theRequest = new Object();
    if(url != null && url != "") {
        if (url.indexOf("?") != -1) {
            var str = url.substr(26);
            strs = str.split("&");
            for (var i = 0; i < strs.length; i++)
                theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
        }
        var urlArr = url.split('%20');
        var userid = sessionStorage.getItem("userId");
        var tableId = theRequest['tableId'];
        var preId = theRequest['preId'];
        var locatime = theRequest['locatime'];
        if (isEmpty(tableId) && isEmpty(preId)) {
            /*                console.log("进入方法11")
                            console.log(preId);
                            console.log(userid)*/
            if (preId != userid) {
                //var urlText = '/hetong/Send_add?preId=' + preId + '&tableId=' + tableId + '&localtime='+locatime;
                //console.log(urlText);
                console.log(JSON.stringify({'url': urlArr.join(' ')}))
                $.ajax({
                    url: '/hetong/Send_add',
                    /*                        dateType: "json",
                                            contentType: "application/json",
                                            type: "post",
                                            data: JSON.stringify({'url': url}),*/
                    type: "get",
                    data: {
                        'url': urlArr.join(' '),
                        'tableId' : tableId,
                        'preId' : preId
                    },
                    success: function (res) {
                        //console.log(res)合同编号为： tableId
                        if (res.msg == "success") {
                            layer.open({
                                anim: 1,
                                title: '注意！',
                                content: '你有新的合同, 请注意查收!',
                                shade: [0.8, '#393D49'],
                                yes: function(index, layero){
                                    layer.close(index);
                                }
                            });
                            sessionStorage.setItem("prevUrl",null);
                            $.ajax({
                                url: '/indexDetails',
                                type: 'POST',
                                success: function (res) {
                                    if (res.msg == "success") {
                                        $('#whole').html(res.data.whole);
                                        $('#finish').html(res.data.confirm);
                                        $('#being').html(res.data.send_notconfirm);
                                        $('#un').html(res.data.notsend);
                                        $('#month').html(res.data.Statistics.m);
                                        $('#season').html(res.data.Statistics.j);
                                        $('#year').html(res.data.Statistics.y);
                                        layui.use('layer', function () {
                                            var layer = layui.layer;
                                            var textArr = "";
                                            for (let i = 1; i <= res.data.RemindInfo.length; i++) {
                                                var text = i + ' > 合同id: ' + res.data.RemindInfo[i - 1].tableId + '  项目名: ' + res.data.RemindInfo[i - 1].projectName + '<br/>';
                                                textArr += text;
                                            }
                                            if (res.data.RemindInfo.length > 0) {
                                                layer.alert(textArr, {
                                                    title: false
                                                    , skin: 'layui-layer-molv' //样式类名
                                                    , closeBtn: 0
                                                }, function () {
                                                    layer.alert('请尽快完成哦!', {
                                                        skin: 'layui-layer-lan'
                                                        , title: false
                                                        , closeBtn: 0
                                                        , anim: 4 //动画类型
                                                    });
                                                });
                                            }
                                        });
                                    }
                                }
                            })
                        } else {
                            if(sessionStorage.getItem("loginId")!=null) {
                                layer.open({
                                    anim: 1,
                                    title: '注意！',
                                    content: res.msg,
                                    shade: [0.8, '#393D49'],
                                    yes: function(index, layero){
                                        layer.close(index);
                                    }
                                });
                            }
                            sessionStorage.setItem("prevUrl",null);
                        }
                    }
                })
            }
        }
    }
</script>
</body>
</html>